Micron Document




Comment (computer programming)
part 26/37 · 66.0 KB total
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
C Lines beginning with 'C' in the first (a.k.a. comment) column are comments
C
WRITE (6,610)
610 FORMAT(12H HELLO WORLD)
END

The following Fortran 90 code fragment shows a more modern line comment syntax; text following !.

! A comment
program comment_test
print '(A)', 'Hello world' ! also a comment
end program

Free-form Fortran, also introduced with Fortran 90, only supports this latter style of comment.

Although not a part of the Fortran Standard, many Fortran compilers offer an optional C-like preprocessor pass. This can be used to provide block comments:

#if 0
This is a block comment spanning
multiple lines.
#endif
program comment_test
print '(A)', 'Hello world' ! also a comment
end program

MATLAB

In MATLAB's programming language, the '%' character indicates a single-line comment. Multi line comments are also available via %{ and %} brackets and can be nested, e.g.

% These are the derivatives for each term
d = [0 -1 0];
%{
 %{
(Example of a nested comment, indentation is for cosmetics (and ignored).)
 %}
We form the sequence, following the Taylor formula.
Note that we're operating on a vector.
%}
seq = d .* (x - c).^n ./(factorial(n))
% We add-up to get the Taylor approximation
approx = sum(seq)

Nim

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────